/*
 * 作者: 侯晓宇
 * 时间: 2017-01-24
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {
	require("jquery");

	var c = require('app/utils/CommonUtils');
	var EventUtils = require('app/utils/EventUtils'); 
	var APIUtils = require('app/utils/APIUtils');
	var win = window;

	var action = require('app/action/ImageClipFrmAction');

	var param = api.pageParam;

	var h = $("#footer").height();

	$("#back").click(function() {
		action.close();
	});

	$("#save").click(function() {
		action.save(param.path)
			.then(function(newPath) {
				c.l(newPath);
				EventUtils.send(api.winName,'updateCover',newPath);
				action.close();
			});
	});


	var FNImageClip = api.require('FNImageClip');

	FNImageClip.open({
		rect: {
			x: 0,
			y: 0,
			w: APIUtils.winW(),
			h: APIUtils.winH() - h
		},
		srcPath: param.path,
		style: {
			mask: 'rgba(12,12,12,0.6)',
			clip: {
				w: APIUtils.winW(),
				h: parseInt(APIUtils.winW() * 0.5625),
				x: 0,
				y: parseInt(APIUtils.winH() / 2) - parseInt(APIUtils.winW() * 0.5625 / 2),
				borderColor: '#FFFFFF',
				borderWidth: 2,
				appearance: 'rectangle'
			}
		},
		mode: 'image',
		fixedOn: api.frameName
	}, function(ret, err) {
	
	});
});